import { Alova } from '@/utils/http/alova/index';

/**
 * @description: 获取用户信息
 */
export function getUserInfo() {
  return Alova.Get<InResult>('/system/web/user/info', {
    meta: {
      isReturnNativeResponse: true,
    },
  });
}

/**
 * @description: 修改用户信息
 */
export function updateUserInfoApi(data) {
  return Alova.Put<InResult>('/system/web/user/edit', data);
}

/**
 * @description: 用户密码登录
 */
export function loginByPasswordApi(data) {
  return Alova.Post<InResult>('/system/auth/login', data, {
    meta: {
      isReturnNativeResponse: true,
    },
  });
}

/**
 * @description: 用户验证码登录
 */
export function loginBySmsApi(data) {
  return Alova.Post<InResult>('/system/auth/login-sms', data, {
    meta: {
      isReturnNativeResponse: true,
    },
  });
}

/**
 * @description: 用户注册
 */
export function register(data) {
  return Alova.Post<InResult>('/system/web/user/signUp', data, {
    meta: {
      isReturnNativeResponse: true,
    },
  });
}

/**
 * @description: 生成滑块
 */
export function getCodeImg() {
  return Alova.Post<InResult>('/system/web/user/get-captcha', {});
}

/**
 * @description: 检查滑块
 */
export function checkCodeImg(data) {
  return Alova.Post<InResult>('/system/web/user/verify/captcha', data, {
    meta: {
      isReturnNativeResponse: true,
    },
  });
}

/**
 * @description: 发送验证码
 */
export function sendCaptchaApi(data) {
  return Alova.Post<InResult>('/system/web/user/send-code', data);
}

/**
 * @description: 用户修改密码
 */
export function changePassword(params, uid) {
  return Alova.Post(`/user/u${uid}/changepw`, { params });
}

/**
 * @description: 用户登出
 */
export function logout() {
  return Alova.Post<InResult>(
    '/system/auth/logout',
    {},
    {
      meta: {
        isReturnNativeResponse: true,
      },
    }
  );
}

/**
 * @description: 修改登录密码
 */
export function updatePasswordApi(data) {
  return Alova.Put<InResult>('/system/web/user/change/password', data);
}

/**
 * @description: 用户中心统计信息
 */
export function getUserCenterInfoApi() {
  return Alova.Get<InResult>('/system/web/user/follow/count');
}

/**
 * @description: 用户粉丝列表
 */
export function getFansListApi(userId, params) {
  return Alova.Get<InResult>('/system/follow/followers/' + userId, { params });
}

/**
 * @description: 用户关注列表
 */
export function getFollowListApi(userId, params) {
  return Alova.Get<InResult>('/system/follow/following/' + userId, { params });
}

/**
 * @description: 关注用户
 */
export function followUserApi(userId) {
  return Alova.Post<InResult>('/system/follow/follow/' + userId);
}

/**
 * @description: 取消关注用户
 */
export function unFollowUserApi(userId) {
  return Alova.Delete<InResult>('/system/follow/follow/' + userId);
}

/**
 * @description: 钱包信息
 */
export function getWalletInfoApi() {
  return Alova.Get<InResult>('/order/wallet/account');
}

/**
 * @description: 流水列表
 */
export function getTransactionApi(userId, params) {
  return Alova.Get<InResult>('/order/wallet/transaction/list', { params });
}
